<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ProductSyncer
 *
 * @author aneto
 */
class ProductSyncer extends Syncer{

	protected function getRequestType(){
		return 'product';
	}

	protected function getWebServiceType(){
		return SimpleWebService::DIRECTO_INPUT;
	}

	protected function mapData(array $pks){
		$q = Doctrine_Query::create()
			->select('
				p.id,
				p.code as Productcode,
				p.barcode as Barcode,
				p.supplier_price as SupplierPrice,
				p.price as Price,
				pt.name as nameEST,
				p.solaris_club_price as SolarisClubPrice,
				p.beauty_club_price as BeautyClubPrice,
				pg.group_id as ProductGroup
				')
			->from('Product p')
			->leftJoin('p.Translation pt WITH pt.lang = ?', 'et')
			->leftJoin('p.ProductGroups pg')
			->whereIn('p.id', $pks)
			->groupBy('p.id')
			->setHydrationMode(Doctrine::HYDRATE_ARRAY);

		$result = $q->execute();

		return $result;
	}


	protected function getRequestParams(array $items){
		return array('xml' => $this->getXmlStr($items));
	}

	protected function getRemotePks(){
		$q = Doctrine_Query::create()
			->select('
					p.code as code
				')
			->from('Product p')
			->whereIn('p.id', $this->getPks())
			->setHydrationMode(Doctrine::HYDRATE_SINGLE_SCALAR);
		return $q->execute();
	}


	protected function  isSuccessfull($response) {
		
	}
}
?>
